package com.msh.automatic.android.control.tools

import android.app.DownloadManager
import android.content.Context
import android.net.Uri
import android.os.Environment

object DownloadUtil {

    fun download(url:String,context: Context){
        val request = DownloadManager.Request(Uri.parse(url))
            .setTitle("正在下载文件")
            .setDescription("请稍候")
            .setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
            .setAllowedOverMetered(true)
            .setAllowedOverRoaming(true)

        val downloadManager = context.getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
        downloadManager.enqueue(request)
    }

}